{{--@extends("base")--}}
@extends("admin.base")
@section("page")
    <style>
        @font-face {
            font-family: "";
        }
    </style>
    <div class="container-fluid p-4">
        <h1>电影类别添加页面</h1>
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body col-4">
                        {{--                        <form id="taypesform" action="insert" method="post">--}}
                        <form  id="tilform" method="post">
                            {{--                            @csrf--}}
                            <input type="hidden" name="id" class="form-control" value="{{isset($ok)?$ok->id:''}}">
                            <div class="col-6 p-1">
                                <label class="form-label" for="formrow-firstname-input">语言：</label>
                                <input type="text" name="til_ch" class="form-control" value="{{isset($ok)?$ok->til_ch:''}}">

                            </div>
                            <div class="col-md-6 p-1 ">
                                <div class="mb-3">
                                    <label class="form-label" for="formrow-email-input">تىل ئايرىمىسى:</label>
                                    <input type="text" name="til_uy" class="form-control" value="{{isset($ok)?$ok->til_uy:''}}"
                                           style="font-family: 'ALKATIP Gezit Tom'">
                                </div>
                            </div>
                            <div class="col-md-6 p-1">
                                <div class="mb-3">
                                    <label class="form-label" for="formrow-password-input">排序:</label>
                                    <input type="number" name="order" class="form-control"
                                           value="{{isset($ok)?$ok->order:''}}">
                                </div>
                            </div>
                        </form>
                        <div class="mt-3 mb-3 p-1">
                            <button onclick="tilsub()" class="btn btn-primary w-md">提交</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section("scripts")
    <script>
        function tilsub() {
            var data = $('#tilform').serialize();
            $.ajax({
                url: "inserttil",  //请求的url地址
                dataType: "json",   //返回格式为json
                async: true,//请求是否异步，默认为异步，这也是ajax重要特性
                headers: {'X-CSRF-TOKEN': '{{csrf_token()}}'},
                data: data,    //参数值
                type: "POST",   //请求方式
                success: function (req) {
                        swal({
                            title: "操作成功",
                            text: req.title,
                            icon: "success",
                            button: "知道了",
                        }).then((willDelete) => {
                            if (willDelete) {
                                location.href = "/tils";
                            }
                        },2000);

                    },

                fail: function (req) {
                        swalll({
                            title: reg.text,
                            text: "发生了错误，请检查网络连接",
                            icon: "warning",
                            buttons: ["知道了"],
                        })
                    }
            });


        }
    </script>
@endsection


